​/*
https://leetcode.cn/problems/set-mismatch/
*/

int* findErrorNums(int* nums, int numsSize, int* returnSize) {

    int* returnnums = (int*)malloc(sizeof(int)*2);
    *returnSize = 2;

    int rep = 0;
    int sum = 0;

    int* hash = (int*) malloc(sizeof(int)*(numsSize + 1));
    for(int i = 0; i <= numsSize; i++){
        hash[i] = 0;
    }

    for(int i = 0; i < numsSize; i++){
        ++hash[nums[i]];
        if(hash[nums[i]] == 2)  rep = nums[i];
        sum += nums[i];
    }

    returnnums[0] = rep;
    int num = (1 + numsSize)*numsSize / 2 - sum;
    returnnums[1] = rep + num;

    return returnnums;
}

​